package dazuoye;

import java.util.*;
import java.lang.*;


public class HTMLSSFormatter implements SSFormatter{
    private static HTMLSSFormatter singletonInstance=null;
    private HTMLSSFormatter(){ }
    public static HTMLSSFormatter getSingletonInstance(){
        if(singletonInstance==null){
            singletonInstance=new HTMLSSFormatter();
        }
        return singletonInstance;
    }
    

    public String formatSS(ScoreSummary scoresummary){
        
        String str="";
        str=str+" <html>"+"\n"+" <body>"+"\n"+"  <center><h2>ScoreReport</h2></center>"+"\n";
        ScoreReport scorereport;
        for(Iterator a=scoresummary.iterator();a.hasNext();){
            scorereport=(ScoreReport)a.next();
            StringBuilder str1=(new StringBuilder().append("<hr>"+"\n"+"<h4>number of scores: "+scorereport.getNumberOfFScores()+" </h4>"+"  <br>"+"  generalscore-examscore-finalscore"));
            FinalScore finalscore;
            for(Iterator b=scorereport.iterator();b.hasNext();){
                finalscore=(FinalScore)b.next();
                ExamScore examscore=finalscore.getExamScore();
                str1=str1.append("\n"+"<p>"+examscore.getCode()+" ");
                str1=str1.append(examscore.getName()+" ");
                str1=str1.append(examscore.getSubject()+" ");
                str1=str1.append(finalscore.getGeneralScore()+" ");
                str1=str1.append(examscore.getScore()+" ");
                str1=str1.append(finalscore.getFinScore()+"\n"+"</p>");
            }
            str=str+str1.toString();
        }
        return str;
    }
}